package com.medicine.manage.block.service.impl;

import com.medicine.manage.block.EncryptUtils;
import com.medicine.manage.block.entity.WeBaseResult;
import com.medicine.manage.block.service.AbstractBlockService;
import com.medicine.manage.block.service.IBlockService;
import com.medicine.manage.block.service.IBlockProcessService;
import com.medicine.manage.domain.Boiling;
import org.springframework.stereotype.Service;

@Service("blockProcessBoiling")
public class BlockProcessBoilingServiceImpl extends AbstractBlockService<Boiling> implements IBlockProcessService<Boiling> {

    private final String INSERT_ONE_METHOD = "insertBoiling";
    private final String SELECT_ONE_METHOD = "selectBoiling";
    private final String UPDATE_METHOD = "updateBoiling";


    @Override
    public WeBaseResult insertProcessObj(Boiling boiling, Long deptId, Long optionUserId) {
        return this.insertOne(boiling, deptId, optionUserId, INSERT_ONE_METHOD);
    }

    @Override
    public WeBaseResult selectProcessObj(Long orderId, Long boilingId, Long deptId, Long optionUserId) {
        return this.selectOne(orderId, boilingId, deptId, optionUserId, SELECT_ONE_METHOD);
    }

    @Override
    public WeBaseResult updateProcessObj(Boiling boiling, Long deptId, Long optionUserId) {
        return this.update(boiling.getOrderId(),  boiling, deptId, optionUserId, UPDATE_METHOD);
    }

    @Override
    protected String createParam(Boiling o, Long optionUserId) {
        StringBuffer param = new StringBuffer();
        param.append(o.getOrderId()).append(IBlockService.SEPARATOR)
                .append(o.getId()).append(IBlockService.SEPARATOR)

                .append(o.getPanId()).append(IBlockService.SEPARATOR)
                .append(o.getWaterInjection()).append(IBlockService.SEPARATOR)
                .append(o.getHotTime()).append(IBlockService.SEPARATOR)
                .append(o.getOptionIndex()).append(IBlockService.SEPARATOR)
                .append(o.getImage1()==null || o.getImage1().equals("") ? "" : EncryptUtils.sha256(o.getImage1())).append(IBlockService.SEPARATOR)
                .append(o.getImage2()==null || o.getImage2().equals("") ? "" :EncryptUtils.sha256(o.getImage2())).append(IBlockService.SEPARATOR)
                .append(o.getImage3()==null || o.getImage3().equals("") ? "" :EncryptUtils.sha256(o.getImage3())).append(IBlockService.SEPARATOR)
                .append(o.getImage4()==null || o.getImage4().equals("") ? "" :EncryptUtils.sha256(o.getImage4())).append(IBlockService.SEPARATOR)
                .append(optionUserId);

        return param.toString();
    }
}
